import axios from "axios";

const getToken = () => {
    return localStorage.getItem('token');
}

const baseurl = 'https://hlx.xiangle6.cn/api';

const req = axios.create({
    baseURL: baseurl,
});

req.interceptors.request.use((config) => {
    return config;
})

req.interceptors.response.use((res) => {
    if ([200].includes(res.data.code)) {
        return Promise.resolve(res.data.data);
    }
    return Promise.reject(new Error('业务 Code 提示错误'));
}, (error) => {
    throw Promise.reject(error);
})

export const getBuildingDetail = (params) => {
    return req.get('/hlx-building/detail', { params });
}

// 信息列表,根据类型types查询不同的基础设施
export const getBuildingList = (params) => {
    return req.get('/hlx-building/list', { params });
}


// 信息列表,根据类型types查询不同的基础设施
export const getRouteList = (params) => {
    return req.get('/hlx-route/list', { params });
}


// 信息列表,根据类型types查询不同的基础设施
export const getRouteDetail = (params) => {
    return req.get('/hlx-route/detail', { params });
}

// 信息列表,根据类型types查询不同的基础设施
export const getBusinessList = (params) => {
    return req.get('/hlx-activity/getBusinessList', { params });
}
